package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.internetofthings.firefightingiot;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.internetofthings.firefightingiot.FireAlarmInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 报警日志控制器
 */
@Action
@RequestMapping(value="fireFightingIOT/historicalAlarmInfo")
public class FireAlarmInfoController extends BaseController {
    @Resource
    public FireAlarmInfoService fireAlarmInfoService;

    /**
     * 历史报警信息列表查询
     * @param
     * page	第几页
     * limit	每页多少条
     * deviceClassify	设备分类:1 电气火灾 2 消防用水 3 烟感 4 可燃气体 5 火灾自动联网 6 消防可视化
     * isHandle	是否处理：false 未处置 true 已处置
     * alarmtime	报警时间
     * businessName	单位名称(模糊查询)
     * alarmType	报警类型
     * starttime	开始时间：筛选alarmtime
     * endtime	结束时间：筛选alarmtime
     * deviceId	设备id
     * number	设备编号(模糊查询)
     * @return
     */
    @At(value = "listHistoricalAlarmInfoListPage", method = RequestMethod.GET, param = { "page","limit" })
    public RespEntity listHistoricalAlarmInfoListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.listHistoricalAlarmInfoListPage(jsonParam);
    }

    /**
     * 字典组查询（目前用到所有系统的列表查询）
     * @param  groupname:字典组
     * @return
     */
    @At(value = "dictList", method = RequestMethod.GET, param = { "groupname"})
    public RespEntity dictList(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.dictList(jsonParam);
    }

    /**
     * 报警类型分组名称
     */
    @At(value = "getAlarmTypeGroupName", method = RequestMethod.GET)
    public RespEntity getAlarmTypeGroupName(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.getAlarmTypeGroupName(jsonParam);
    }

    /**
     * 处置功能
     * @param
     * id	单位设备详细日志表的主键id
     * handlePerson	处理人员
     * infoconfirm	信息确认：1 报警 2 误报 3 测试
     * handleRemark	处理备注
     * ids	分模块的日志id数组
     * number	设备编号
     * alarmType	报警类型:对应字典表报警类型
     * handletime	处理时间
     * @return
     */
    @At(value = "handle", method = RequestMethod.POST)
    public RespEntity handle(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.handle(jsonParam);
    }

    /**
     * 报警信息详情
     * @param  id:单位设备详细日志id
     * @return
     */
    @At(value = "detail", method = RequestMethod.GET, param = { "id" })
    public RespEntity detail(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.detail(jsonParam);
    }

    /**
     * 报警日志添加
     * @param
     * number	设备编号
     * content	报警内容
     * alarmType	报警类型:对应字典表报警类型
     * id	主键id
     * alarmtime	报警时间
     * @return
     */
    @At(value = "add", method = RequestMethod.POST)
    public RespEntity add(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.add(jsonParam);
    }

    /**
     * 导出报警信息
     * @param
     * deviceClassify	设备分类:1 电气火灾 2 消防用水 3 烟感 4 可燃气体 5 火灾自动联网 6 消防可视化
     * isHandle	是否处理：false 未处置 true 已处置
     * alarmtime	报警时间
     * businessName	单位名称(模糊查询)
     * alarmType	报警类型
     * alarmTypeName	报警类型名称
     * number	设备编号(模糊查询)
     * @return
     */
    @At(value = "export", method = RequestMethod.POST)
    public RespEntity export(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.export(jsonParam);
    }

    /**
     * 处置模块分类功能(总历史记录点处置时触发)
     * @param
     * id	单位设备详细日志表的主键id
     * handlePerson	处理人员
     * infoconfirm	信息确认：1 报警 2 误报 3 测试
     * batchHandle	是否批处理：是：true  不是：false
     * handleRemark	处理备注
     * deviceClassify	设备分类:1 电气火灾 2 消防用水 3 烟感 4 可燃气体 5 火灾自动联网 6 消防可视化
     * handletime	处理时间
     * @return
     */
    @At(value = "typeHandle", method = RequestMethod.POST, param = { "id","deviceClassify" })
    public RespEntity typeHandle(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.typeHandle(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 一键处置
     * @Date Created in 15:10 2022/5/7
     * @Param [jsonParam]
     */

    @At(value = "oneClickHandle", method = RequestMethod.POST)
    public RespEntity oneClickHandle(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.oneClickHandle(jsonParam);
    }

    /**
     * 判断是否有未读报警信息接口(单位用)
     * @param
     * @return
     */
    @At(value = "isHaveUnReadLog", method = RequestMethod.GET)
    public RespEntity isHaveUnReadLog(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.isHaveUnReadLog(jsonParam);
    }

    /**
     * 日志改为已读状态
     * @param
     * id    设备报警日志id	是
     * @return
     */
    @At(value = "updateUnReadState", method = RequestMethod.POST, param = { "id" })
    public RespEntity updateUnReadState(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.updateUnReadState(jsonParam);
    }

    /**
     * 前端是否对这个用户做报警处理
     * @param
     *
     * @return
     */
    @At(value = "isAlarm", method = RequestMethod.GET, param = { "alarmId" })
    public RespEntity isAlarm(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.isAlarm(jsonParam);
    }

    /**
     * 烟感报警消音
     * @param jsonParam
     * @return
     */
    @At(value = "alarmSilencer", method = RequestMethod.POST, param = { "number" })
    public RespEntity alarmSilencer(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.alarmSilencer(jsonParam);
    }

    /**
     * 查询是否存在未处置的报警信息
     * @param jsonParam
     * @return
     */
    @At(value = "alarmCount", method = RequestMethod.GET)
    public RespEntity alarmCount(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.alarmCount(jsonParam);
    }

    /**
     * 报警事件列表
     * @param jsonParam
     * @return
     */
    @At(value = "eventList", method = RequestMethod.GET)
    public RespEntity eventList(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.eventList(jsonParam);
    }

    /**
     * 报警日历数据
     * @param jsonParam
     * @return
     */
    @At(value = "alarmCalendarList", method = RequestMethod.GET)
    public RespEntity alarmCalendarList(@RequestBody(required = false) JSONObject jsonParam) {
        return fireAlarmInfoService.alarmCalendarList(jsonParam);
    }

}
